package com.ssd.controller.consumer;


import com.ssd.entity.dto.request.SeizeCouponReqDTO;
import com.ssd.entity.dto.response.CouponInfoResDTO;
import com.ssd.service.ICouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.util.List;

/**
 * <p>
 * 运营端-我的优惠券表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-21
 */
@RestController("consumerCouponController")
@RequestMapping("/consumer/coupon")
@Api(tags = "用户端-我的优惠券表控制器")
@Validated
public class CouponController {
    @Resource
    private ICouponService couponService;

    @GetMapping("/my")
    @ApiOperation(value = "我的优惠券列表")
    public List<CouponInfoResDTO> queryMyCouponForPage(@RequestParam(value = "lastId", required = false)Long lastId, @Max(3 ) @Min(1) @RequestParam(value = "status" ,required = true)  Integer status){
        return couponService.queryMyCouponForPage(lastId,status);
    }


    /**
     * 用户抢券接口
     * @param seizeCouponReqDTO 抢券请求参数
     */
    @ApiOperation(value = "抢券接口")
    @PostMapping("/seize")
    public void seizeCoupon(@RequestBody SeizeCouponReqDTO seizeCouponReqDTO){
        couponService.seizeCoupon(seizeCouponReqDTO);
    }
}
